package com.example.surveyapplication;

import help.Utility;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class SettingActivity extends Activity implements OnClickListener {
	TextView lblSignOut;
	Button btnChangeEmail;
	Button btnChangePassword;
	Button btnChangePersonal;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting);
		setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
	
		initComponents();
	}
	
	private void initComponents() {
		lblSignOut = (TextView)findViewById(R.id.lblSignOut_Setting);
		btnChangeEmail = (Button)findViewById(R.id.btnChangeEmail_Setting);
		btnChangePassword = (Button)findViewById(R.id.btnChangePassword_Setting);
		btnChangePersonal = (Button)findViewById(R.id.btnChangePersonal_Setting);
		
		lblSignOut.setOnClickListener(this);
		btnChangeEmail.setOnClickListener(this);
		btnChangePassword.setOnClickListener(this);
		btnChangePersonal.setOnClickListener(this);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.setting, menu);
		return true;
	}

	public void onClick(View view) {
		Intent intent;
		
		switch (view.getId()) {
		case R.id.btnChangeEmail_Setting:
			intent = new Intent(this, SettingEmailActivity.class);
			startActivity(intent);
			break;
		case R.id.btnChangePassword_Setting:
			intent = new Intent(this, SettingPasswordActivity.class);
			startActivity(intent);
			break;
		case R.id.btnChangePersonal_Setting:
			intent = new Intent(this, SettingPersonalActivity.class);
			startActivity(intent);
			break;
		case R.id.lblSignOut_Setting:
			Utility.signOut();
			intent = new Intent(this, SignInActivity.class);
			startActivity(intent);
			finish();
			break;
		default:
			break;
		}
	}
}
